<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Rep\PurchaseRep;
use Illuminate\Http\Request;

class Purchase extends Controller
{
    //采购单
    protected $rep;

    public function __construct(Request $request)
    {
        $this->rep = new PurchaseRep();
    }

    /**
     * 获取采购单列表
     * product_name
     * color_id
     *
     */
    public function getPurchaseList(Request $request){
        $params = $request->all();
        $data = $this->rep->getPurchaseListRep($params);
        return re(0,$data,'success');
    }

    //添加采购单
    public function createPurchase(Request $request){
        $params = $request->only(['purchase_number','buyer','purchase_date','delivery_date','child']);
        $data = $this->rep->createPurchaseRep($params);
        return re(0,$data,'success');
    }

    public function setPurchaseStatus(Request $request){

        $params = $request->only(['id','status','user_id']);
        $id = $params['id'];
        $status = $params['status'];
        $user_id = $params['user_id'];
        $data = $this->rep->setPurchaseStatusRep($id,$status,$user_id);
        return re(0,$data,'success');
    }


}
